package com.zdsoft.crm.service.clue.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zdsoft.crm.dao.clue.IClueMapper;
import com.zdsoft.crm.entity.Clue;
import com.zdsoft.crm.entity.ClueSource;
import com.zdsoft.crm.service.clue.IClueService;
import com.zdsoft.crm.vo.PageVo;

@Service
@Transactional
public class ClueServiceImpl implements IClueService{

	@Autowired
	IClueMapper clueMapper;
	
	@Override
	public PageVo findPage(Integer pageNum, Integer pageSize) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(clueMapper.pageList(beginIndex, endIndex));
		pageVo.setTotalCount(clueMapper.totalCount("","").intValue());
		return pageVo;
	}
	/**
	 * 删除
	 */
	@Override
	public int delete(String id) {
		return clueMapper.delete(id);
	}

	@Override
	public Clue getClueInfo(String id) {
		
		
		return clueMapper.getClueInfo(id);
	}
	@Override
	public ClueSource getClueSource(String id) {
		return clueMapper.getClueSource(id);
	}
	@Override
	public List<ClueSource> getClueSourceAll() {
		return clueMapper.getClueSourceAll();
	}
	@Override
	public String getUserName(String id) {
		return clueMapper.getUserName(id);
	}
	@Override
	public String getUserId(String username) {
		return clueMapper.getUserId(username);
	}
	@Override
	public int update(Clue clue) {
		return clueMapper.update(clue);
	}
	
	@Override
	public int save(Clue clue) {
		int i=clueMapper.save(clue);
		return i;
	}
	@Override
	public List<Clue> getClueAll() {
		return clueMapper.getClueAll();
	}
	@Override
	public PageVo pageListWhere(Integer pageNum, Integer pageSize, String criteriaType, String content) {
		PageVo pageVo = new PageVo();
		pageVo.setPageNum(pageNum);
		pageVo.setPageSize(pageSize);
		int beginIndex = (pageNum - 1) * pageSize;
		int endIndex = beginIndex + pageSize;
		pageVo.setList(clueMapper.pageListWhere(beginIndex, endIndex,criteriaType,content));
		pageVo.setTotalCount(clueMapper.totalCount(criteriaType,content).intValue());
		return pageVo;
	}
	

	
}
